﻿using CommandService;
using Entity;
using Newtonsoft.Json;
using Newtonsoft.Json.Linq;
using System;
using System.Collections.Generic;
using System.Data;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Web.UI.WebControls;

namespace BLL
{
  public  class ChartBLL:SysFrameWork.PubMethod
    {
        Commands cmd;
        ReturnResult rsl;
        Statistics.StatisticsBLL tjBLL;
        public ChartBLL()
        {
            cmd = new Commands();
            tjBLL = new Statistics.StatisticsBLL();
        }
        /// <summary>
        /// 条码数量统计(件数/待入库件数)
        /// </summary>
        /// <param name="condition"></param>
        /// <returns></returns>
        public ReturnResult BarCodeDayTotal(string condition)
        {
            rsl = new ReturnResult();
            try
            {
                Dictionary<string, object> gdic = new Dictionary<string, object>();
                #region 数据获取
                StringBuilder sb = new StringBuilder();
                sb.Append("select barCode,wareHouse from bar_ProductBarCode_info");
                sb.Append("  where barStatus !='bar-drop' ");
                sb.Append(" and convert(date,happenDate, 20)='" + getNowDate() + "' ");
                var dTable = cmd.GetDataTable(sb.ToString());
                gdic["total"] = dTable.Rows.Count;
                int yrk = 0,wrk=0;
                if (dTable.Rows.Count > 0)
                {
                    var dr = dTable.Select("wareHouse <>'bcp'");
                    yrk = dr.Length;
                    dr = dTable.Select("wareHouse ='bcp'");
                    wrk = dr.Length;
                }
                gdic["barIn"] = yrk.ToString();
                gdic["needIn"] = wrk.ToString();
                #endregion

                sb.Clear();
                sb.Append("select barCode from bar_ProductBarCode_info");
                sb.Append("  where barStatus !='bar-drop' and wareHouse='bcp'");
                sb.Append(" and convert(date,happenDate, 20)<'" + getNowDate() + "' ");
                dTable = cmd.GetDataTable(sb.ToString());
                gdic["delay"] = dTable.Rows.Count;
                rsl.Result = true;
                rsl.Data = gdic;

            }
            catch (Exception ex)
            {
                rsl.Message = ex.Message;
            }
            return rsl;
        }
      

    }
}
